#include <msp430g2231.h>

#define CLOCK_PIN BIT0
#define DATA_PIN BIT6

volatile unsigned int i;

void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigIO(void);
void ShiftOut(char data);

void main(void)
{
  ConfigWDT();
  ConfigClocks();
  ConfigIO();
  
  while(1)
  {
  	for(i = 0; i < 1000; i++)
  	{
  		//do nothing
  	}
  	ShiftOut(BIT0|BIT2|BIT5);
  }
}

void ConfigWDT(void)
 {
 WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer	
 }

void ConfigClocks(void)
 {
 if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                       
   FaultRoutine();		                    // If calibration data is erased
 				                            // run FaultRoutine()
  BCSCTL1 = CALBC1_1MHZ; 					// Set range
  DCOCTL = CALDCO_1MHZ;  					// Set DCO step + modulation 
  BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO
  IFG1 &= ~OFIFG;                           // Clear OSCFault flag
  BCSCTL2 |= SELM_0 + DIVM_0 + DIVS_3;      // MCLK = DCO/1, SMCLK = DCO/8	
 }
 
void FaultRoutine(void)
 {
   P1OUT = BIT0;                            // P1.0 on (red LED)
   while(1); 			                    // TRAP
 }
 
void ConfigIO(void)
 {
  P1DIR = BIT0 + BIT6;                      // P1.6 and P1.0 outputs
  P1OUT = 0;                                // Port 1 off	
 }
 
 void ShiftOut(char data)
 {
 	
 }
